package com.bulemobi.activity.ac_user_centre;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.BaseAdapter;
import com.bulemobi.net.tsz.afinal.FinalBitmap;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public abstract class BaseListAdapter<T extends Serializable> extends BaseAdapter{
	
	protected Context mContext;
    protected FinalBitmap fb;
	protected List<T> mList = new ArrayList<T>();// 列表List
	protected LayoutInflater mInflater;// 布局管理
	protected OnCustomListener listener;
    protected OnCustomClickListener clickListener;
    protected OnCustomItemLongListener longListener;

	/**
	 * 构造器
	 * 
	 * @param context
	 * @param list
	 *            起始数据
	 */
	protected BaseListAdapter(Context context, List<T> list) {
        this.mContext = context;
        this.mList = list;
        mInflater = LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
        int count =  (mList == null) ? 0 : mList.size();
		return count;
	}

	@Override
	public T getItem(int position) {
		return mList.get(position);
	}

	@Override
	public long getItemId(int positionId) {
		return positionId;
	}
	
	/**
	 * 设置适配器上，某个控件的监听事件
	 * 
	 * @param listener
	 */
	public void setOnCustomListener(OnCustomListener listener) {
		this.listener = listener;
	}

    public void setClickListener(OnCustomClickListener clickListener) {
        this.clickListener = clickListener;
    }

    public void setLongListener(OnCustomItemLongListener longListener) {
        this.longListener = longListener;
    }

    /**
     * 自定义监听器
     *
     * @author david
     *
     */
    public interface OnCustomListener {
        public void onCustomerListener(View v, int position);
    }
    public interface OnCustomClickListener {
        public void onClick(int clickId, int position);
    }
    public interface OnCustomItemLongListener {
        public void onLongClick(View v, int position);
    }
}
